#ifndef AST_STATEMENT_LABELED_STMT_H
#define AST_STATEMENT_LABELED_STMT_H

#include "../ASTNode.h"

class sym;
class Statement;
class ConstantExpr;

/*
C99   6.8.1
labeled-statement:
		identifier   :   statement
		case   constant-expression   :   statement
		default   :   statement
*/
class LabeledStmt : public ASTNode
{
public:
	enum{
		identifier_stmt,
		case_stmt,
		default_stmt,
	};
protected:
	LabeledStmt(void)
		: ASTNode(ASTNode::labeled_statement){};
public:
	LabeledStmt(Statement *pStmt, ConstantExpr *pConsExpr )
		: ASTNode(ASTNode::labeled_statement)
		, m_iType(case_stmt)
		, m_pCaseExpr(pConsExpr)
		, m_pCaseStmt(pStmt){};

	LabeledStmt(sym *pIdentifier, Statement *pStmt)
		: ASTNode(ASTNode::labeled_statement)
		, m_iType(identifier_stmt)
		, m_pIdentifier(pIdentifier)
		, m_pIdentifierStmt(pStmt) {};

	LabeledStmt(Statement *pStmt)
		: ASTNode(ASTNode::labeled_statement)
		, m_iType(default_stmt)
		, m_pDefaultStmt(pStmt) {};

	virtual ~LabeledStmt(void);

	virtual void				codeGen();
protected:
	tiny_int					m_iType;
	union{
		struct{
			Statement *				m_pIdentifierStmt;
			sym *				m_pIdentifier;
		};
		
		Statement *				m_pDefaultStmt;
		struct{
			Statement *			m_pCaseStmt;
			ConstantExpr *		m_pCaseExpr;
		};
	};
};


#endif

